from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_wtf.csrf import CSRFProtect
from flask import session
from redis import StrictRedis
from flask_session import Session
from flask_script import Manager
from flask_migrate import MigrateCommand,Migrate

class Config():
    DEBUG=True
    SQLALCHEMY_DATABASE_URI="mysql://root:123456@127.0.0.1:3306/hehe"
    SQLALCHEMY_TRACK_MODIFICATIONS=True
    REDIS_HOST='127.0.0.1'
    REDIS_PORT='6379'
    SESSION_REDIS='redis'
    SESSION_KEY_PREFIX=StrictRedis(host=REDIS_HOST,port=REDIS_PORT,db=1)
    SESSION_USE_SIGNER=True
    SESSION_PERMANENT=False
    PERMANENT_SESSION_LEFETIME=86400
    SECRET_KEY="aasdsfagfdgf"

app =Flask(__name__)
app.config.from_object(Config)
db =SQLAlchemy(app)
CSRFProtect(app)
redis_he =StrictRedis(host=Config.REDIS_HOST,port=Config.REDIS_PORT,decode_responses=True)
Session(app)
manage =Manager(app)
Migrate(app,db)
manage.add_command('db',MigrateCommand)
@app.route('/')
def haihai():
    return '成功'

if __name__ == '__main__':
    app.run()